Skip to content

Conversation

@adamnemecek
Copy link

No description provided.

@mach-kernel
Copy link

mach-kernel commented Feb 26, 2021

This would be useful for me too. My use case is wanting to move from an xpc_object_t into a Rust HashMap:

let mut hm: HashMap<String, XPCObject> = HashMap::new();

let block = ConcreteBlock::new(|key: *const c_char, value: xpc_object_t| {
    let str_key = unsafe { CStr::from_ptr(key).to_string_lossy().to_string() };
    hm.insert(str_key, XPCObject { data: value });
});

EDIT: Was able to use Rc<RefCell<HashMap>> instead

@adamnemecek
Copy link
Author

@mach-kernel I wonder if it's a good idea to have two versions, a Fn and a FnMut version. I think that just a FnMut version should suffice. If you are already dealing with these APIs, your immutability is fucked anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants